﻿using PHMEE.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;

namespace PHMEE
{
    public class MainenanceAdviceRepository : BaseRepository<MainenanceAdvice, Guid>, IMainenanceAdviceRepository
    {
        public MainenanceAdviceRepository(IDbContextProvider<PHMEEDbContext> dbContextProvider) : base(dbContextProvider)
        {
        }
        
        /// <inheritdoc />
        public async Task<List<MainenanceAdvice>> GetListByFaultCodesAsync(IEnumerable<string> faultCodes)
        {
            var query = await GetQueryableAsync();
            
            return await query
                .Where(ma => faultCodes.Contains(ma.Code))
                .ToListAsync();
        }
    }
}
